package com.gitee.gen.jenkins;

import com.offbytwo.jenkins.JenkinsServer;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class JobApi {
    private JenkinsServer jenkinsServer;

    JobApi() {
        jenkinsServer = JenkinsConnect.connection();
    }

    public void buildJob(String jobName){
        try {
            jenkinsServer.getJob(jobName).build();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void buildParamJob(String jobName,String projectName){
        try {
            // 设置参数值
            Map<String,String> param = new HashMap<>();
            param.put("projectName",projectName);
            jenkinsServer.getJob(jobName).build(param);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
